home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 April / CHIP 1996 aprilis (CD06).zip / CHIP_CD06.ISO / microsft / vb4 / vb4-3.cab / blanker.frm < prev    next >
Text File  |  1995-08-15  |  26KB  |  730 lines

  1. VERSION 4.00
  2. Begin VB.Form DemoForm 
  3.    BackColor       =   &H00000000&
  4.    Caption         =   "Screen Blanker Demo"
  5.    ClientHeight    =   4425
  6.    ClientLeft      =   960
  7.    ClientTop       =   1965
  8.    ClientWidth     =   7470
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   1
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H00000000&
  19.    Height          =   5115
  20.    Icon            =   "BLANKER.frx":0000
  21.    Left            =   900
  22.    LinkMode        =   1  'Source
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   4425
  25.    ScaleWidth      =   7470
  26.    Top             =   1335
  27.    Width           =   7590
  28.    Begin VB.Timer Timer1 
  29.       Interval        =   1
  30.       Left            =   6960
  31.       Top             =   120
  32.    End
  33.    Begin VB.CommandButton cmdStartStop 
  34.       BackColor       =   &H00000000&
  35.       Caption         =   "Start Demo"
  36.       Default         =   -1  'True
  37.       Height          =   390
  38.       Left            =   240
  39.       TabIndex        =   0
  40.       Top             =   120
  41.       Width           =   1830
  42.    End
  43.    Begin VB.PictureBox picBall 
  44.       AutoSize        =   -1  'True
  45.       BackColor       =   &H00000000&
  46.       BorderStyle     =   0  'None
  47.       ForeColor       =   &H00FFFFFF&
  48.       Height          =   480
  49.       Left            =   1800
  50.       Picture         =   "BLANKER.frx":030A
  51.       ScaleHeight     =   480
  52.       ScaleWidth      =   480
  53.       TabIndex        =   1
  54.       Top             =   720
  55.       Visible         =   0   'False
  56.       Width           =   480
  57.    End
  58.    Begin VB.Image imgMoon 
  59.       Height          =   480
  60.       Index           =   8
  61.       Left            =   6330
  62.       Picture         =   "BLANKER.frx":0614
  63.       Top             =   3765
  64.       Visible         =   0   'False
  65.       Width           =   480
  66.    End
  67.    Begin VB.Line linLineCtl 
  68.       BorderColor     =   &H00FF0000&
  69.       BorderWidth     =   5
  70.       Visible         =   0   'False
  71.       X1              =   240
  72.       X2              =   4080
  73.       Y1              =   2760
  74.       Y2              =   2760
  75.    End
  76.    Begin VB.Image imgMoon 
  77.       Height          =   480
  78.       Index           =   7
  79.       Left            =   5760
  80.       Picture         =   "BLANKER.frx":091E
  81.       Top             =   3720
  82.       Visible         =   0   'False
  83.       Width           =   480
  84.    End
  85.    Begin VB.Image imgMoon 
  86.       Height          =   480
  87.       Index           =   6
  88.       Left            =   5160
  89.       Picture         =   "BLANKER.frx":0C28
  90.       Top             =   3720
  91.       Visible         =   0   'False
  92.       Width           =   480
  93.    End
  94.    Begin VB.Image imgMoon 
  95.       Height          =   480
  96.       Index           =   5
  97.       Left            =   4560
  98.       Picture         =   "BLANKER.frx":0F32
  99.       Top             =   3720
  100.       Visible         =   0   'False
  101.       Width           =   480
  102.    End
  103.    Begin VB.Image imgMoon 
  104.       Height          =   480
  105.       Index           =   4
  106.       Left            =   3960
  107.       Picture         =   "BLANKER.frx":123C
  108.       Top             =   3720
  109.       Visible         =   0   'False
  110.       Width           =   480
  111.    End
  112.    Begin VB.Image imgMoon 
  113.       Height          =   480
  114.       Index           =   3
  115.       Left            =   3360
  116.       Picture         =   "BLANKER.frx":1546
  117.       Top             =   3720
  118.       Visible         =   0   'False
  119.       Width           =   480
  120.    End
  121.    Begin VB.Image imgMoon 
  122.       Height          =   480
  123.       Index           =   2
  124.       Left            =   2760
  125.       Picture         =   "BLANKER.frx":1850
  126.       Top             =   3720
  127.       Visible         =   0   'False
  128.       Width           =   480
  129.    End
  130.    Begin VB.Image imgMoon 
  131.       Height          =   480
  132.       Index           =   1
  133.       Left            =   2160
  134.       Picture         =   "BLANKER.frx":1B5A
  135.       Top             =   3720
  136.       Visible         =   0   'False
  137.       Width           =   480
  138.    End
  139.    Begin VB.Image imgMoon 
  140.       Height          =   480
  141.       Index           =   0
  142.       Left            =   1560
  143.       Picture         =   "BLANKER.frx":1E64
  144.       Top             =   3720
  145.       Visible         =   0   'False
  146.       Width           =   480
  147.    End
  148.    Begin VB.Shape shpClone 
  149.       BackColor       =   &H00000000&
  150.       BackStyle       =   1  'Opaque
  151.       BorderColor     =   &H00FF0000&
  152.       FillColor       =   &H000000FF&
  153.       Height          =   1215
  154.       Index           =   0
  155.       Left            =   240
  156.       Top             =   720
  157.       Visible         =   0   'False
  158.       Width           =   1410
  159.    End
  160.    Begin VB.Shape Shape1 
  161.       Height          =   15
  162.       Left            =   960
  163.       Top             =   1080
  164.       Width           =   15
  165.    End
  166.    Begin VB.Menu mnuOption 
  167.       Caption         =   "&Options"
  168.       Begin VB.Menu mnuLineCtlDemo 
  169.          Caption         =   "&Jumpy Line"
  170.          Checked         =   -1  'True
  171.       End
  172.       Begin VB.Menu mnuCtlMoveDemo 
  173.          Caption         =   "Re&bound"
  174.       End
  175.       Begin VB.Menu mnuImageDemo 
  176.          Caption         =   "&Spinning Moon"
  177.       End
  178.       Begin VB.Menu mnuShapeDemo 
  179.          Caption         =   "&Madhouse"
  180.       End
  181.       Begin VB.Menu mnuPSetDemo 
  182.          Caption         =   "&Confetti"
  183.       End
  184.       Begin VB.Menu mnuLineDemo 
  185.          Caption         =   "C&rossfire"
  186.       End
  187.       Begin VB.Menu mnuCircleDemo 
  188.          Caption         =   "Rainbo&w Rug"
  189.       End
  190.       Begin VB.Menu mnuScaleDemo 
  191.          Caption         =   "Co&lor Bars"
  192.       End
  193.       Begin VB.Menu sep1 
  194.          Caption         =   "-"
  195.       End
  196.       Begin VB.Menu mnuExit 
  197.          Caption         =   "E&xit"
  198.       End
  199.    End
  200. End
  201. Attribute VB_Name = "DemoForm"
  202. Attribute VB_Creatable = False
  203. Attribute VB_Exposed = False
  204. Option Explicit
  205. ' Declare a variable to track animation frame.
  206. Dim Shared FrameNum
  207. ' Declare the X- and Y-coordinate variables to track position.
  208. Dim Shared XPos
  209. Dim Shared YPos
  210. ' Declare a variable flag to stop graphic routines in Do Loops.
  211. Dim Shared DoFlag
  212. ' Declare a variable to track moving controls.
  213. Dim Shared Motion
  214. ' Declare form variables for color.
  215. Dim R
  216. Dim G
  217. Dim B
  218.  
  219. Private Sub CircleDemo()
  220.     ' Declare local variables.
  221.     Dim Radius
  222.     ' Create random RGB colors.
  223.     R = 255 * Rnd
  224.     G = 255 * Rnd
  225.     B = 255 * Rnd
  226.     ' Position center of circles in the center of the form.
  227.     XPos = ScaleWidth / 2
  228.     YPos = ScaleHeight / 2
  229.     ' Generate a radius between 0 and almost half the form's height.
  230.     Radius = ((YPos * 0.9) + 1) * Rnd
  231.     ' Draw a circle on the form.
  232.     Circle (XPos, YPos), Radius, RGB(R, G, B)
  233. End Sub
  234.  
  235. Private Sub cmdStartStop_Click()
  236. ' Declare local variables.
  237. Dim UnClone
  238. Dim MakeClone
  239. Dim X1
  240. Dim Y1
  241.     Select Case DoFlag
  242.         Case True
  243.             cmdStartStop.Caption = "Start Demo"
  244.             DoFlag = False
  245.             mnuOption.Enabled = True
  246.             If mnuCtlMoveDemo.Checked = True Then
  247.                 ' Hide bouncing graphic again.
  248.                 picBall.Visible = False
  249.             ElseIf mnuLineDemo.Checked = True Then
  250.                 ' Remove lines from the form.
  251.                 Cls
  252.             ElseIf mnuShapeDemo.Checked = True Then
  253.                 ' Remove all dynamically loaded Shape controls.
  254.                 For UnClone = 1 To 20
  255.                     Unload shpClone(UnClone)
  256.                 Next UnClone
  257.                 ' Reset background color of form to black.
  258.                 DemoForm.BackColor = QBColor(0)
  259.                 ' Refresh form so color change takes effect.
  260.                 Refresh
  261.             ElseIf mnuPSetDemo.Checked = True Then
  262.                 ' Remove confetti bits from form.
  263.                 Cls
  264.             ElseIf mnuLineCtlDemo.Checked = True Then
  265.                 ' Hide Line control again.
  266.                 linLineCtl.Visible = False
  267.                 ' Remove any stray pixels left after hiding line.
  268.                 Cls
  269.             ElseIf mnuImageDemo.Checked = True Then
  270.                 ' Hide bouncing graphic again.
  271.                 imgMoon(0).Visible = False
  272.             ElseIf mnuScaleDemo.Checked = True Then
  273.                 ' Clear the form.
  274.                 Cls
  275.                 ' Return form to the default scale.
  276.                 Scale
  277.             ElseIf mnuCircleDemo.Checked = True Then
  278.                 ' Remove the circles from the form.
  279.                 Cls
  280.             End If
  281.         Case False
  282.             cmdStartStop.Caption = "Stop Demo"
  283.             DoFlag = True
  284.             mnuOption.Enabled = False
  285.             If mnuCtlMoveDemo.Checked = True Then
  286.                 ' Make the bouncing graphic (picture box control) visible.
  287.                 picBall.Visible = True
  288.                 ' Determine initial motion of bouncing graphic at random.
  289.                 ' Settings are 1 to 4.  The value of the Motion variable determines
  290.                 ' what part of the Do Loop routine runs.
  291.                 Motion = Int(4 * Rnd + 1)
  292.             ElseIf mnuLineDemo.Checked = True Then
  293.                 ' Initialize the random-number generator.
  294.                 Randomize
  295.                 ' Set the line width.
  296.                 DrawWidth = 2
  297.                 ' Set the initial X- and Y-coordinates to a random location on the form.
  298.                 X1 = Int(DemoForm.Width * Rnd + 1)
  299.                 Y1 = Int(DemoForm.Height * Rnd + 1)
  300.             ElseIf mnuShapeDemo.Checked = True Then
  301.                 ' Dynamically load a control array of 20 shape controls on the form.
  302.                 For MakeClone = 1 To 20
  303.                     Load shpClone(MakeClone)
  304.                 Next MakeClone
  305.             ElseIf mnuPSetDemo.Checked = True Then
  306.                 ' Set the thickness of the confetti bits.
  307.                 DrawWidth = 5
  308.             ElseIf mnuLineCtlDemo.Checked = True Then
  309.                 ' Make the line control visible.
  310.                 linLineCtl.Visible = True
  311.                 ' Set thickness of the line as it will appear.
  312.                 DrawWidth = 7
  313.             ElseIf mnuImageDemo.Checked = True Then
  314.                 ' Make the bouncing graphic (image control) visible.
  315.                 imgMoon(0).Visible = True
  316.                 ' Set initial animation frame.
  317.                 FrameNum = 0
  318.                 ' Determine the initial motion of the bouncing graphic at random.
  319.                 ' Settings are 1 to 4.  The Value of the Motion variable determines
  320.                 ' what part of the Do Loop routine runs.
  321.                 Motion = Int(4 * Rnd + 1)
  322.             ElseIf mnuScaleDemo.Checked = True Then
  323.                 ' Initialize the random-number generator.
  324.                 Randomize
  325.                 ' Set the width of the box outlines so boxes don't overlap.
  326.                 DrawWidth = 1
  327.                 ' Set the value of the X-coordinate to the left edge of form.
  328.                 ' Set the first box's X-coordinate = 1, second box = 2, and so on.
  329.                 ScaleLeft = 1
  330.                 ' Set the Y-coordinate of top edge of form to 10.
  331.                 ScaleTop = 10
  332.                 ' Set the number of units of the form width to a random number between
  333.                 ' 3 and 12.  This changes the number of boxes drawn each time the
  334.                 ' routine starts.
  335.                 ScaleWidth = Int(13 * Rnd + 3)
  336.                 ' Set the number of units in the form height to -10.  Then the height of all boxes
  337.                 ' varies from 0 to 10, and Y-coordinates start at the bottom of the form.
  338.                 ScaleHeight = -10
  339.             ElseIf mnuCircleDemo.Checked = True Then
  340.                 ' Define the width of the circle outline.
  341.                 DrawWidth = 1
  342.                 ' Draw circles as dashed lines.
  343.                 DrawStyle = vbDash
  344.                 ' Draw lines using the XOR pen, combining colors found in the pen or
  345.                 ' in the display, but not in both.
  346.                 DrawMode = vbXorPen
  347.             End If
  348.     End Select
  349. End Sub
  350.  
  351. Private Sub CtlMoveDemo()
  352.     Select Case Motion
  353.     Case 1
  354.         ' Move the graphic left and up by 20 twips using the Move method.
  355.         picBall.Move picBall.Left - 20, picBall.Top - 20
  356.         ' If the graphic reaches the left edge of the form, move it to the right and up.
  357.         If picBall.Left <= 0 Then
  358.             Motion = 2
  359.         ' If the graphic reaches the top edge of the form, move it to the left and down.
  360.         ElseIf picBall.Top <= 0 Then
  361.             Motion = 4
  362.         End If
  363.     Case 2
  364.         ' Move the graphic right and up by 20 twips.
  365.         picBall.Move picBall.Left + 20, picBall.Top - 20
  366.         ' If the graphic reaches the right edge of the form, move it to the left and up.
  367.         ' Routine determines the right edge of the form by subtracting the graphic
  368.         ' width from the form width.
  369.         If picBall.Left >= (DemoForm.Width - picBall.Width) Then
  370.             Motion = 1
  371.         ' If the graphic reaches the top edge of the form, move it to the right and down.
  372.         ElseIf picBall.Top <= 0 Then
  373.             Motion = 3
  374.         End If
  375.     Case 3
  376.         ' Move the graphic right and down by 20 twips.
  377.         picBall.Move picBall.Left + 20, picBall.Top + 20
  378.         ' If the graphic reaches the right edge of the form, move it to the left and down.
  379.         If picBall.Left >= (DemoForm.Width - picBall.Width) Then
  380.             Motion = 4
  381.         ' If the graphic reaches the bottom edge of the form, move it to the right and up.
  382.         ' Routine determines the bottom of the form by subtracting
  383.         ' the graphic height from the form height less 680 twips for the height
  384.         ' of title bar and menu bar.
  385.         ElseIf picBall.Top >= (DemoForm.Height - picBall.Height) - 680 Then
  386.             Motion = 2
  387.         End If
  388.     Case 4
  389.         ' Move the graphic left and down by 20 twips.
  390.         picBall.Move picBall.Left - 20, picBall.Top + 20
  391.         ' If the graphic reaches the left edge of the form, move it to the right and down.
  392.         If picBall.Left <= 0 Then
  393.             Motion = 3
  394.         ' If the graphic reaches the bottom edge of the form, move it to the left and up.
  395.         ElseIf picBall.Top >= (DemoForm.Height - picBall.Height) - 680 Then
  396.             Motion = 1
  397.         End If
  398.     End Select
  399. End Sub
  400.  
  401. Private Sub Delay()
  402.     Dim Start
  403.     Dim Check
  404.     Start = Timer
  405.     Do Until Check >= Start + 0.15
  406.         Check = Timer
  407.     Loop
  408. End Sub
  409.  
  410. Private Sub Form_Load()
  411.     DoFlag = False
  412. End Sub
  413.  
  414. Private Sub Form_Resize()
  415.     If mnuScaleDemo.Checked = True And DemoForm.WindowState = 0 Then
  416.         ' Initialize the random-number generator.
  417.         Randomize
  418.         ' Set the width of the box outlines to narrow so the boxes don't overlap.
  419.         DrawWidth = 1
  420.         ' Set the value of the X-coordinate of the left edge of the form to 1.
  421.         ' This makes it easy to set the position for each box.  The first box has
  422.         ' an X-coordinate of 1, the second has an X-coordinate of 2, and so on.
  423.         ScaleLeft = 1
  424.         ' Set the value of the Y-coordinate of the top edge of the form to 10.
  425.         ScaleTop = 10
  426.         ' Set the number of units in the width of the form to a random number between
  427.         ' 3 and 12.  This changes the number of boxes that are drawn each time the user
  428.         ' starts this routine.
  429.         ScaleWidth = Int(13 * Rnd + 3)
  430.         ' Set the number of units in the height of the form to -10.  This has
  431.         ' two effects.  First, all the boxes then have a height that varies from 0 to 10.
  432.         ' Second, the negative value causes the Y-coordinates to begin at the bottom
  433.         ' edge of the form instead of at the top.
  434.         ScaleHeight = -10
  435.     End If
  436. End Sub
  437.  
  438. Private Sub Form_Unload(Cancel As Integer)
  439.     End
  440. End Sub
  441.  
  442. Private Sub ImageDemo()
  443.     Select Case Motion
  444.     Case 1
  445.         ' Move the graphic to the left and up by 100 twips using the Move method.
  446.         imgMoon(0).Move imgMoon(0).Left - 100, imgMoon(0).Top - 100
  447.         ' Increment animation to next frame.
  448.         IncrFrame
  449.         ' If the graphic reaches the left edge of the form, move right and up.
  450.         If imgMoon(0).Left <= 0 Then
  451.             Motion = 2
  452.         ' If the graphic reaches the top edge of the form, move left and down.
  453.         ElseIf imgMoon(0).Top <= 0 Then
  454.             Motion = 4
  455.         End If
  456.     Case 2
  457.         ' Move the graphic right and up by 100 twips.
  458.         imgMoon(0).Move imgMoon(0).Left + 100, imgMoon(0).Top - 100
  459.         ' Increment animation to next frame.
  460.         IncrFrame
  461.         ' If the graphic reaches the right edge of the form, move left and up.
  462.         ' Routine determines the right edge of the form by subtracting
  463.         ' the graphic width from the control width.
  464.         If imgMoon(0).Left >= (DemoForm.Width - imgMoon(0).Width) Then
  465.             Motion = 1
  466.         ' If the graphic reaches the top edge of the form, move right and down.
  467.         ElseIf imgMoon(0).Top <= 0 Then
  468.             Motion = 3
  469.         End If
  470.     Case 3
  471.         ' Move the graphic right and down by 100 twips.
  472.         imgMoon(0).Move imgMoon(0).Left + 100, imgMoon(0).Top + 100
  473.         ' Increment animation to next frame.
  474.         IncrFrame
  475.         ' If the graphic reaches the right edge of the form, move left and down.
  476.         If imgMoon(0).Left >= (DemoForm.Width - imgMoon(0).Width) Then
  477.             Motion = 4
  478.         ' If the graphic reaches bottom edge of form, move right and up.
  479.         ' Routine determines the bottom edge of the form by subtracting the graphic
  480.         ' height from the form height minus 680 twips for the height of the title
  481.         ' bar and menu bar.
  482.         ElseIf imgMoon(0).Top >= (DemoForm.Height - imgMoon(0).Height) - 680 Then
  483.             Motion = 2
  484.         End If
  485.     Case 4
  486.         ' Move the graphic left and down by 100 twips.
  487.         imgMoon(0).Move imgMoon(0).Left - 100, imgMoon(0).Top + 100
  488.         ' Increment animation to next frame.
  489.         IncrFrame
  490.         ' If the graphic reaches the left edge of the form, move right and down.
  491.         If imgMoon(0).Left <= 0 Then
  492.             Motion = 3
  493.         ' If the graphic reaches the bottom edge of the form, move left and up.
  494.         ElseIf imgMoon(0).Top >= (DemoForm.Height - imgMoon(0).Height) - 680 Then
  495.             Motion = 1
  496.         End If
  497.     End Select
  498. End Sub
  499.  
  500. Private Sub IncrFrame()
  501.     ' Increment frame number.
  502.     FrameNum = FrameNum + 1
  503.     ' Control array with animation frames has elements 0 to 7. At the eighth
  504.     ' frame, reset the frame number to 0 for an endless animation loop.
  505.     If FrameNum > 8 Then
  506.         FrameNum = 1
  507.     End If
  508.     ' Set the Picture property of the image control to the Picture property of the current frame.
  509.     imgMoon(0).Picture = imgMoon(FrameNum).Picture
  510.     ' Pause display so animation isn't too fast.
  511.     Delay
  512. End Sub
  513.  
  514. Private Sub LineCtlDemo()
  515.     ' Set X- and Y-coordinates (left/right position) of the line's start position to a
  516.     ' random location on the form.
  517.     linLineCtl.X1 = Int(DemoForm.Width * Rnd)
  518.     linLineCtl.Y1 = Int(DemoForm.Height * Rnd)
  519.     ' Set X- and Y-coordinates (left/right position) of line's end position to
  520.     ' a random location on the form.
  521.     linLineCtl.X2 = Int(DemoForm.Width * Rnd)
  522.     linLineCtl.Y2 = Int(DemoForm.Height * Rnd)
  523.     ' Clear the form to remove any stray pixels.
  524.     Cls
  525.     ' Pause display before moving the line again.
  526.     Delay
  527. End Sub
  528.  
  529. Private Sub LineDemo()
  530.     ' Declare local variables.
  531.     Dim X2
  532.     Dim Y2
  533.     ' Create random RGB colors.
  534.     R = 255 * Rnd
  535.     G = 255 * Rnd
  536.     B = 255 * Rnd
  537.     ' Set the end point of the line control to a random location on the form.
  538.     X2 = Int(DemoForm.Width * Rnd + 1)
  539.     Y2 = Int(DemoForm.Height * Rnd + 1)
  540.     ' Using the Line method, draw from current coordinates to current end
  541.     ' point, giving line a random color. Each line starts where the last
  542.     ' line ends.
  543.     Line -(X2, Y2), RGB(R, G, B)
  544. End Sub
  545.  
  546. Private Sub mnuCircleDemo_Click()
  547.     Cls
  548.     mnuCtlMoveDemo.Checked = False
  549.     mnuLineDemo.Checked = False
  550.     mnuShapeDemo.Checked = False
  551.     mnuPSetDemo.Checked = False
  552.     mnuLineCtlDemo.Checked = False
  553.     mnuImageDemo.Checked = False
  554.     mnuScaleDemo.Checked = False
  555.     mnuCircleDemo.Checked = True
  556. End Sub
  557.  
  558. Private Sub mnuCtlMoveDemo_Click()
  559.     Cls
  560.     mnuCtlMoveDemo.Checked = True
  561.     mnuLineDemo.Checked = False
  562.     mnuShapeDemo.Checked = False
  563.     mnuPSetDemo.Checked = False
  564.     mnuLineCtlDemo.Checked = False
  565.     mnuImageDemo.Checked = False
  566.     mnuScaleDemo.Checked = False
  567.     mnuCircleDemo.Checked = False
  568. End Sub
  569.  
  570. Private Sub mnuExit_Click()
  571.     End
  572. End Sub
  573.  
  574. Private Sub mnuImageDemo_Click()
  575.     Cls
  576.     mnuCtlMoveDemo.Checked = False
  577.     mnuLineDemo.Checked = False
  578.     mnuShapeDemo.Checked = False
  579.     mnuPSetDemo.Checked = False
  580.     mnuLineCtlDemo.Checked = False
  581.     mnuImageDemo.Checked = True
  582.     mnuScaleDemo.Checked = False
  583.     mnuCircleDemo.Checked = False
  584. End Sub
  585.  
  586. Private Sub mnuLineCtlDemo_Click()
  587.     Cls
  588.     mnuCtlMoveDemo.Checked = False
  589.     mnuLineDemo.Checked = False
  590.     mnuShapeDemo.Checked = False
  591.     mnuPSetDemo.Checked = False
  592.     mnuLineCtlDemo.Checked = True
  593.     mnuImageDemo.Checked = False
  594.     mnuScaleDemo.Checked = False
  595.     mnuCircleDemo.Checked = False
  596. End Sub
  597.  
  598. Private Sub mnuLineDemo_Click()
  599.     Cls
  600.     mnuCtlMoveDemo.Checked = False
  601.     mnuLineDemo.Checked = True
  602.     mnuShapeDemo.Checked = False
  603.     mnuPSetDemo.Checked = False
  604.     mnuLineCtlDemo.Checked = False
  605.     mnuImageDemo.Checked = False
  606.     mnuScaleDemo.Checked = False
  607.     mnuCircleDemo.Checked = False
  608. End Sub
  609.  
  610. Private Sub mnuPSetDemo_Click()
  611.     Cls
  612.     mnuCtlMoveDemo.Checked = False
  613.     mnuLineDemo.Checked = False
  614.     mnuShapeDemo.Checked = False
  615.     mnuPSetDemo.Checked = True
  616.     mnuLineCtlDemo.Checked = False
  617.     mnuImageDemo.Checked = False
  618.     mnuScaleDemo.Checked = False
  619.     mnuCircleDemo.Checked = False
  620. End Sub
  621.  
  622. Private Sub mnuScaleDemo_Click()
  623.     Cls
  624.     mnuCtlMoveDemo.Checked = False
  625.     mnuLineDemo.Checked = False
  626.     mnuShapeDemo.Checked = False
  627.     mnuPSetDemo.Checked = False
  628.     mnuLineCtlDemo.Checked = False
  629.     mnuImageDemo.Checked = False
  630.     mnuScaleDemo.Checked = True
  631.     mnuCircleDemo.Checked = False
  632. End Sub
  633.  
  634. Private Sub mnuShapeDemo_Click()
  635.     Cls
  636.     mnuCtlMoveDemo.Checked = False
  637.     mnuLineDemo.Checked = False
  638.     mnuShapeDemo.Checked = True
  639.     mnuPSetDemo.Checked = False
  640.     mnuLineCtlDemo.Checked = False
  641.     mnuImageDemo.Checked = False
  642.     mnuScaleDemo.Checked = False
  643.     mnuCircleDemo.Checked = False
  644. End Sub
  645.  
  646. Private Sub PSetDemo()
  647.     ' Create random RGB colors.
  648.     R = 255 * Rnd
  649.     G = 255 * Rnd
  650.     B = 255 * Rnd
  651.     ' XPos sets the horizontal position of a confetti bit to a random location on the form.
  652.     XPos = Rnd * ScaleWidth
  653.     ' YPos sets the vertical position of a confetti bit to a random location on the form.
  654.     YPos = Rnd * ScaleHeight
  655.     ' Draw a confetti bit at XPos, YPos. Assign the confetti bit a random color.
  656.     PSet (XPos, YPos), RGB(R, G, B)
  657. End Sub
  658.  
  659. Private Sub ScaleDemo()
  660.     ' Declare local variables.
  661.     Dim Box
  662.     ' Creates the same number of boxes as units in the width of the form.
  663.     For Box = 1 To ScaleWidth
  664.         ' Create random RGB colors.
  665.         R = 255 * Rnd
  666.         G = 255 * Rnd
  667.         B = 255 * Rnd
  668.         ' Draw boxes using te Line method with the B (box) F (filled) options.
  669.         ' Boxes start at each X-coordinate determined by ScaleWidth and at
  670.         ' a Y-coordinate of 0 (bottom of form). Each box is 1 unit wide and
  671.         ' has a random height between 0 and 10. Fill the box with a random color.
  672.         Line (Box, 0)-Step(1, (Int(11 * Rnd))), RGB(R, G, B), BF
  673.     Next Box
  674.     ' Pause to display all boxes before redraw.
  675.     Delay
  676. End Sub
  677.  
  678. Private Sub ShapeDemo()
  679.     ' Declare local variables.
  680.     Dim CloneID
  681.     ' Create random RGB colors.
  682.     R = 255 * Rnd
  683.     G = 255 * Rnd
  684.     B = 255 * Rnd
  685.     ' Set the form's background color to a random value.
  686.     DemoForm.BackColor = RGB(R, G, B)
  687.     ' Select a random shape control in the control array.
  688.     CloneID = Int(20 * Rnd + 1)
  689.     ' XPos and YPos set position of selected shape control to a random
  690.     ' location on the form.
  691.     XPos = Int(DemoForm.Width * Rnd + 1)
  692.     YPos = Int(DemoForm.Height * Rnd + 1)
  693.     ' Set the shape of the selected shape control to a random shape.
  694.     shpClone(CloneID).Shape = Int(6 * Rnd)
  695.     ' Set the height and width of a selected shape control to a random size between
  696.     ' 500 and 2500 twips.
  697.     shpClone(CloneID).Height = Int(2501 * Rnd + 500)
  698.     shpClone(CloneID).Width = Int(2501 * Rnd + 500)
  699.     ' Set the background color and DrawMode property of the shape control to a random color.
  700.     shpClone(CloneID).BackColor = QBColor(Int(15 * Rnd))
  701.     shpClone(CloneID).DrawMode = Int(16 * Rnd + 1)
  702.     ' Move the selected shape control to XPos, YPos.
  703.     shpClone(CloneID).Move XPos, YPos
  704.     ' Make the selected shape control visible.
  705.     shpClone(CloneID).Visible = True
  706.     ' Wait briefly before selecting and changing the next shape control.
  707.     Delay
  708. End Sub
  709.  
  710. Private Sub Timer1_Timer()
  711.     If mnuCtlMoveDemo.Checked And DoFlag = True Then
  712.         CtlMoveDemo
  713.     ElseIf mnuLineDemo.Checked And DoFlag = True Then
  714.         LineDemo
  715.     ElseIf mnuShapeDemo.Checked And DoFlag = True Then
  716.         ShapeDemo
  717.     ElseIf mnuPSetDemo.Checked And DoFlag = True Then
  718.         PSetDemo
  719.     ElseIf mnuLineCtlDemo.Checked And DoFlag = True Then
  720.         LineCtlDemo
  721.     ElseIf mnuImageDemo.Checked And DoFlag = True Then
  722.         ImageDemo
  723.     ElseIf mnuScaleDemo.Checked And DoFlag = True Then
  724.         ScaleDemo
  725.     ElseIf mnuCircleDemo.Checked And DoFlag = True Then
  726.         CircleDemo
  727.     End If
  728. End Sub
  729.  
  730.